package com.sjyp.cms.commons.interceptor;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.kit.StrKit;

import java.util.HashMap;
import java.util.Map;

public class FrontCurrentNavInterceptor implements Interceptor {
    private static Map<String, Integer> currentKeys = new HashMap<>();
    static {
        currentKeys.put("/", 1);
        currentKeys.put("/about", 2);
        currentKeys.put("/cases", 3);
        currentKeys.put("/cooperation", 4);
        currentKeys.put("/dailyChemicals", 5);
        currentKeys.put("/services", 6);
        currentKeys.put("/training", 7);
    }

    @Override
    public void intercept(Invocation inv) {
        inv.invoke();
        inv.getController().setAttr("currentKey", (null == currentKeys.get(inv.getActionKey())) ? 1 : currentKeys.get(inv.getActionKey()));
    }
}
